"""
家庭成员相关的 Pydantic 模型
"""

from datetime import datetime

from pydantic import BaseModel, EmailStr

from src.models.family_model import FamilyRelationship, FamilyRole


class FamilyMemberBase(BaseModel):
    """家庭成员基础模型"""

    username: str
    email: EmailStr
    full_name: str
    family_id: int
    role: FamilyRole = FamilyRole.MEMBER
    relationship: FamilyRelationship | None = None
    is_active: bool = True


class FamilyMemberCreate(FamilyMemberBase):
    """创建家庭成员模型"""

    password: str


class FamilyMemberUpdate(BaseModel):
    """更新家庭成员模型"""

    username: str | None = None
    email: EmailStr | None = None
    full_name: str | None = None
    family_id: str | None = None
    role: FamilyRole | None = None
    relationship: FamilyRelationship | None = None
    is_active: bool | None = None


class FamilyMemberResponse(FamilyMemberBase):
    """家庭成员响应模型"""

    id: int
    created_at: datetime
    updated_at: datetime | None = None
    family_name: str | None = None

    model_config = {"from_attributes": True}


class FamilyMemberList(BaseModel):
    """家庭成员列表响应模型"""

    family_members: list[FamilyMemberResponse]
    total: int
    skip: int
    limit: int
